#ifndef __LOADMANAGER_H__
#define __LOADMANAGER_H__

#include <cassert>
#include <string>
#include <map>

template < class T >
class LoadManager
{
public:
	LoadManager( ) 
	{
	}

	~LoadManager( )
	{
		for ( std::map< std::wstring, T* >::iterator i = xmap.begin(); i != xmap.end(); ++i )
		{
			delete i->second;
		}
	}

	
	T* get( std::wstring fileURL )
	{
		T* result = 0;

		std::map< std::wstring, T* >::iterator finded = xmap.find( fileURL );

		if ( finded != xmap.end() )
		{
			result = finded->second;
		}
		else
		{
			// TODO add using factory method
		}

		return result;
	}
	
	void add( std::wstring fileURL, T* type )
	{
		assert( type && !fileURL.empty() );

		std::pair< std::wstring, T* >	pair( fileURL, type );
		xmap.insert( pair );
	}
	
private:
	std::map< std::wstring, T* >	xmap;
};

#endif